package logic

import (
	"context"
	"github.com/zeromicro/go-zero/core/logx"
	"group-card/model/entity"
	"group-card/rpc/card/cardclient"
	"group-card/rpc/card/internal/svc"
)

type TraceabilityDeleteLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewTraceabilityDeleteLogic(ctx context.Context, svcCtx *svc.ServiceContext) *TraceabilityDeleteLogic {
	return &TraceabilityDeleteLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *TraceabilityDeleteLogic) TraceabilityDelete(in *cardclient.TraceabilityDeleteRequest) (*cardclient.TraceabilityDeleteResponse, error) {
	var ctx context.Context
	err := l.svcCtx.TraceabilityModel.Delete(ctx, &entity.CardTraceabilityReq{
		Id: in.Id,
	})

	if err != nil {
		return nil, err
	}

	return &cardclient.TraceabilityDeleteResponse{}, nil
}
